﻿namespace GoodAdmin.CodeGenerator;

public class FieldInfo
{
    /// <summary>
    /// 字段名称
    /// </summary>
    public string ColumnName { get; set; }
    /// <summary>
    /// 字段描述
    /// </summary>
    public string ColumnDescription { get; set; }
    /// <summary>
    /// 字段长度
    /// </summary>
    public int Length { get; set; }
    /// <summary>
    /// 数字精度
    /// </summary>
    public string DecimalDigits { get; set; }
    /// <summary>
    /// 字段类型
    /// </summary>
    public string ColumnDataType { get; set; }
    /// <summary>
    /// 是否是主键
    /// </summary>
    public bool IsPrimaryKey { get; set; } = false;
    /// <summary>
    /// 是否允许为空
    /// </summary>
    public bool IsNullable { get; set; }
}

/// <summary>
/// 配置菜单对象映射
/// </summary>
public class FieldInfoMapper : IRegister
{
    public void Register(TypeAdapterConfig config)
    {
        config.ForType<DbColumnInfo, FieldInfo>()
            .Map(t => t.ColumnName, o => o.DbColumnName)
            .Map(t => t.ColumnDataType, o => o.DataType);
    }
}
